package com.dongdongshop.consume;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.service.item.ItemServiceI;
import com.dongdongshop.service.search.SearchService;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
@RocketMQMessageListener(topic = "code-topic",consumerGroup = "my-code-topic2",messageModel= MessageModel.BROADCASTING)
public class SearchConsume implements RocketMQListener<Long[]>{

    @Reference
    private SearchService elasticSearchService;

    @Reference
    private ItemServiceI itemService;

    @Override
    public void onMessage(Long[] ids) {
        try {
            elasticSearchService.saveItemElasticSearch(ids);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
